package com.liujit.standard.basis.generator.engine.base;

import com.liujit.standard.basis.generator.action.model.TableInfo;
import com.liujit.standard.basis.generator.engine.config.*;
import com.liujit.standard.basis.generator.engine.config.*;
import lombok.Data;

import java.util.List;

/**
 * @Description 模板生成父类
 * @Author LiuJun
 * @Date 2020/8/13 2:06 下午
 */
@Data
public class BaseTemplateEngine {

    /**
     * 全局配置
     */
    protected ContextConfig contextConfig;

    protected ControllerConfig controllerConfig;

    protected ServiceConfig serviceConfig;

    protected MapperConfig mapperConfig;

    protected ModelConfig modelConfig;

    protected QueryConfig queryConfig;

    protected List<TableInfo> tableInfo;

    protected String columnStr;

    public void initConfig() {
        if (this.contextConfig == null) {
            this.contextConfig = new ContextConfig();
        }
        contextConfig.init();
        if (this.controllerConfig == null) {
            this.controllerConfig = new ControllerConfig();
        }
        this.controllerConfig.setContextConfig(this.contextConfig);
        controllerConfig.init();
        if (this.serviceConfig == null) {
            this.serviceConfig = new ServiceConfig();
        }
        this.serviceConfig.setContextConfig(this.contextConfig);
        serviceConfig.init();
        if (this.mapperConfig == null) {
            this.mapperConfig = new MapperConfig();
        }
        this.mapperConfig.setContextConfig(this.contextConfig);
        mapperConfig.init();
        if (this.modelConfig == null) {
            this.modelConfig = new ModelConfig();
        }
        this.modelConfig.setContextConfig(this.contextConfig);
        modelConfig.init();
        if (this.queryConfig == null) {
            this.queryConfig = new QueryConfig();
        }
        this.queryConfig.setContextConfig(this.contextConfig);
        queryConfig.init();
    }
}
